package net.tv90.bfmccoreqqbot.command;

import net.tv90.bfmccoreqqbot.api.WebSocketClientInitializer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;

public class ClientCommand extends WebSocketClientInitializer implements CommandExecutor {

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (label.equalsIgnoreCase("client")) {
            if (args.length == 0) {
                sender.sendMessage("/client connect");
                sender.sendMessage("/client debug");
                return true;
            }
            if (args[0].equalsIgnoreCase("connect")) {
                try {
                    init(config.getUrl());
                } catch (Exception e) {
                    e.printStackTrace();
                }
                return true;
            }
            if (args[0].equalsIgnoreCase("debug")) {
                config.setDebug(!config.isDebug());
                sender.sendMessage("Debug: " + config.isDebug());
                return true;
            }
        }
        return false;
    }

}
